﻿using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AudioConverter
{
    public class WavConverter
    {
        private WavConverter() { }
        public static readonly WavConverter Instance = new WavConverter();

        public string Convert(string srcFilePath, string destFilePath, int rate, int bits, int channels)
        {
            try
            {
                WaveFormat target = new WaveFormat(rate, bits, channels);
                WaveStream stream = new WaveFileReader(srcFilePath);
                WaveFormatConversionStream str = new WaveFormatConversionStream(target, stream);
                WaveFileWriter.CreateWaveFile(destFilePath, str);
            }
            catch (Exception err)
            {
                return (err.Message);
            }
            return ("");
        }
    }
}
